package io.ouka.jvm.hotspot.selfread.domain;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/**
 * @author ouka
 * CodeAttribute
 */
public class CodeAttribute {
    private int attributeNameIndex;
    private int attributeLength;
    private int masStack;
    private int maxLocals;
    private int codeLength;
    private Code codes;

    private int exceptionTableLength;
    private int attributesCount;
    private Map<String, AttributeInfo> attributes = new HashMap<>();
    //未解析的异常表 以后解析
    private byte[] exceptionTable;

    public byte[] getExceptionTable() {
        return exceptionTable;
    }

    public void setExceptionTable(byte[] exceptionTable) {
        this.exceptionTable = exceptionTable;
    }

    public int getAttributeNameIndex() {
        return attributeNameIndex;
    }

    public void setAttributeNameIndex(int attributeNameIndex) {
        this.attributeNameIndex = attributeNameIndex;
    }

    public int getAttributeLength() {
        return attributeLength;
    }

    public void setAttributeLength(int attributeLength) {
        this.attributeLength = attributeLength;
    }

    public int getMasStack() {
        return masStack;
    }

    public void setMasStack(int masStack) {
        this.masStack = masStack;
    }

    public int getMaxLocals() {
        return maxLocals;
    }

    public void setMaxLocals(int maxLocals) {
        this.maxLocals = maxLocals;
    }

    public int getCodeLength() {
        return codeLength;
    }

    public void setCodeLength(int codeLength) {
        this.codeLength = codeLength;
    }

    public Code getCodes() {
        return codes;
    }

    public void setCodes(Code codes) {
        this.codes = codes;
    }

    public int getExceptionTableLength() {
        return exceptionTableLength;
    }

    public void setExceptionTableLength(int exceptionTableLength) {
        this.exceptionTableLength = exceptionTableLength;
    }

    public int getAttributesCount() {
        return attributesCount;
    }

    public void setAttributesCount(int attributesCount) {
        this.attributesCount = attributesCount;
    }

    public Map<String, AttributeInfo> getAttributes() {
        return attributes;
    }

    public void setAttributes(Map<String, AttributeInfo> attributes) {
        this.attributes = attributes;
    }

    @Override
    public String toString() {
        return "CodeAttribute{" +
                "attributeNameIndex=" + attributeNameIndex +
                ", attributeLength=" + attributeLength +
                ", masStack=" + masStack +
                ", maxLocals=" + maxLocals +
                ", codeLength=" + codeLength +
                ", codes=" + codes +
                ", exceptionTableLength=" + exceptionTableLength +
                ", attributesCount=" + attributesCount +
                ", attributes=" + attributes +
                ", exceptionTable=" + Arrays.toString(exceptionTable) +
                '}';
    }
}
